/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020.
 * Description: kaslr architecture related lib functions
 * Author: wangzhu
 * Create: 2020-07-15
 */
#include <linux/printk.h>
#include <linux/reboot.h>
#include <linux/rtos/kaslr.h>
#include <asm/memory.h>

void kaslr_debug_info(void)
{
	pr_notice("virtual start addr offset is %lx\n", kaslr_offset());
}
#ifdef CONFIG_RTOS_KSNAPSHOT
EXPORT_SYMBOL_NS(kaslr_debug_info, RTOS_DEBUG_KSNAPSHOT);
#endif

static int kaslr_reboot_print(struct notifier_block *this,
				unsigned long event, void *ptr)
{
	pr_info("Kernel Offset: 0x%lx\n", kaslr_offset());
	return 0;
}

static struct notifier_block kaslr_reboot_notifier = {
	.notifier_call = kaslr_reboot_print,
};

static int kaslr_reboot_init(void)
{
	return register_reboot_notifier(&kaslr_reboot_notifier);
}

late_initcall(kaslr_reboot_init);
